package cn.imokay.juc.captainSynchronized;

public class ObjectLock implements Runnable {

    static ObjectLock objectLock = new ObjectLock();

    @Override
    public void run() {
        synchronized (this) {
            System.out.println(Thread.currentThread().getName());
            System.out.println(Thread.currentThread().getName() + "结束");
        }
    }

    public static void main(String[] args) {
        Thread t1 = new Thread(objectLock);
        Thread t2 = new Thread(objectLock);
        t1.start();
        t2.start();

        while (t1.isAlive() || t2.isAlive()) {

        }
        System.out.println("finish");
    }
}
